package com.xyhy.core.jackson.deser;

import java.io.IOException;
import java.time.LocalDateTime;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.xyhy.core.utils.time.LocalDateUtil;

public class LocalDateTime4UTCDeserializer extends StdDeserializer<LocalDateTime> {
  private static final long serialVersionUID = 1L;

  public final static LocalDateTime4UTCDeserializer instance = new LocalDateTime4UTCDeserializer();

  protected LocalDateTime4UTCDeserializer(Class<LocalDateTime> t) {
    super(t);
  }

  protected LocalDateTime4UTCDeserializer() {
    this(null);
  }

  @Override
  public LocalDateTime deserialize(JsonParser jsonparser, DeserializationContext context) throws IOException {
    return LocalDateUtil.parseLocalDateTime(Long.parseLong(jsonparser.getText()));
  }
}
